Dynomotion

Group: DynoMotion Message: 919 From: b.burig@yahoo.com Date: 2/16/2011
Subject: Making analog servo with KFlop + Kanalog
I have no idea how to use the low voltage ADCs on JP12 of Kanalog board. Or how to set up an analog loop on the Kanalog. Servoes are not new to me, made hundreds of all types.

Can I sum 2 inputs?
Can I invert the polarity of an input?

I want to make an analog servo with PID loop with analog command generated by a temperature monitoring device. This input would control the temperature loop by outputting a PWM signal (say less than 60 cycles) to an Opto output (say IO 148) to control a heater.

In addition, I want to make another loop using a humidity sensor. It could be a simple on-off control, so I would set a reference, and read the input voltage (input to ADC) and compare to the reference. If needed this may need to expanded to PID loop as well.

Is there a manual for Kanalog.
Group: DynoMotion Message: 920 From: Tom Kerekes Date: 2/16/2011
Subject: Re: Making analog servo with KFlop + Kanalog
To use an ADC as the feedback for a servo loop select Axis Input Mode = ADC on the Configuration Screen.
 
You can specify Input Gains and Offsets.  Setting a Gain of -1 would invert the input.
 
If you need to sum 2 inputs you would need to write a C Program to do this.
 
There is no direct support for that slow of a PWM output to an opto output.  But you can do it with a C program something like shown below.  Configure the servo axis as a dummy DAC output so the axis calculates the  ch0->Output value, but have the C program use the value to control the opto output.
 
The added Kanalog I/O is described under the Kanalog Section here:
 
 
I hope this helps
TK
 
 
#include "KMotionDef.h"
main()
{
    int v,i=0,k;
 
    for (;;)
    {
        WaitNextTimeSlice();
        v=ch0->Output;  // desired output
  
        k = ((i&1)   << 7)|  // bit reverse i
            ((i&2)   << 5)|
            ((i&4)   << 3)|
            ((i&8)   << 1)|
            ((i&16)  >> 1)|
            ((i&32)  >> 3)|
            ((i&64)  >> 5)|
            ((i&128) >> 7);
 
       if (k >= v)
            SetBit(148);
        else
            ClearBit(148);
  
        i = ++i & 255;  // 8 bit counter
    }
}

 

Group: DynoMotion Message: 921 From: b.burig@yahoo.com Date: 2/16/2011
Subject: Re: Making analog servo with KFlop + Kanalog
To get started I tried to read the values of ADC0 that I had a small voltage on JP6 ADC0 using the console command ADC0. result is always 0.
I used the console to set DACO=2000 and I can see that on the analog IO screen but not on JP11 DAC0.
What am I doing wrong.
Bob

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> To use an ADC as the feedback for a servo loop select Axis Input Mode = ADC on
> the Configuration Screen.
>
> You can specify Input Gains and Offsets.  Setting a Gain of -1 would invert the
> input.
>
> If you need to sum 2 inputs you would need to write a C Program to do this.
>
> There is no direct support for that slow of a PWM output to an opto output.  But
> you can do it with a C program something like shown below.  Configure the servo
> axis as a dummy DAC output so the axis calculates the  ch0->Output value, but
> have the C program use the value to control the opto output.
>
> The added Kanalog I/O is described under the Kanalog Section here:
>
> http://www.dynomotion.com/Help
>
> I hope this helps
> TK
>
>
> #include "KMotionDef.h"
> main()
> {
>     int v,i=0,k;
>  
>     for (;;)
>     {
>         WaitNextTimeSlice();
>         v=ch0->Output;  // desired output
>   
>         k = ((i&1)   << 7)|  // bit reverse i
>             ((i&2)   << 5)|
>             ((i&4)   << 3)|
>             ((i&8)   << 1)|
>             ((i&16)  >> 1)|
>             ((i&32)  >> 3)|
>             ((i&64)  >> 5)|
>             ((i&128) >> 7);
>  
>        if (k >= v)
>             SetBit(148);
>         else
>             ClearBit(148);
>   
>         i = ++i & 255;  // 8 bit counter
>     }
> }
>
>
>  
>
>
>
> ________________________________
> From: "b.burig@..." <b.burig@...>
> To: DynoMotion@yahoogroups.com
> Sent: Wed, February 16, 2011 9:23:04 AM
> Subject: [DynoMotion] Making analog servo with KFlop + Kanalog
>
>  
> I have no idea how to use the low voltage ADCs on JP12 of Kanalog board. Or how
> to set up an analog loop on the Kanalog. Servoes are not new to me, made
> hundreds of all types.
>
> Can I sum 2 inputs?
> Can I invert the polarity of an input?
>
> I want to make an analog servo with PID loop with analog command generated by a
> temperature monitoring device. This input would control the temperature loop by
> outputting a PWM signal (say less than 60 cycles) to an Opto output (say IO 148)
> to control a heater.
>
>
> In addition, I want to make another loop using a humidity sensor. It could be a
> simple on-off control, so I would set a reference, and read the input voltage
> (input to ADC) and compare to the reference. If needed this may need to expanded
> to PID loop as well.
>
> Is there a manual for Kanalog.
>
Group: DynoMotion Message: 922 From: Tom Kerekes Date: 2/16/2011
Subject: Re: Making analog servo with KFlop + Kanalog
Hi Bob,
 
That sounds like a hardware problem.  All it should take is power-up, then DAC0=2000, and JP11 DAC0 should change.  If not, then there is a hardware problem.  Note that if you have an axis enabled and it is writing to the DAC then it will immediately overwrite any DAC command sent from the Console, so make sure all axes are disabled when you perform the test.
 
Is the Kanalog LED on?  One common problem is that KFLOP+Kanalog draws too much power to be USB powered.  You must remove the KFLOP J3 jumper and supply external +5V.
 
Regards
TK

Group: DynoMotion Message: 923 From: b.burig@yahoo.com Date: 2/17/2011
Subject: Re: Making analog servo with KFlop + Kanalog
Ah-ha. DACs do output to the terminal strip, but it can't be read by looking at the screw, I have to make contact to the wire clamp. That qualifies as a wiring error I guess.
ADCs stil can't be read by the Console using ADC<N> even though the Analog Status shows various input voltages present.

No power issue, I've been using external 500W computer Pwr Sup.

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Bob,
>
> That sounds like a hardware problem.  All it should take is power-up, then
> DAC0=2000, and JP11 DAC0 should change.  If not, then there is a hardware
> problem.  Note that if you have an axis enabled and it is writing to the DAC
> then it will immediately overwrite any DAC command sent from the Console, so
> make sure all axes are disabled when you perform the test.
>
> Is the Kanalog LED on?  One common problem is that KFLOP+Kanalog draws too much
> power to be USB powered.  You must remove the KFLOP J3 jumper and supply
> external +5V.
>
> Regards
> TK
>
>
>
>
> ________________________________
> From: "b.burig@..." <b.burig@...>
> To: DynoMotion@yahoogroups.com
> Sent: Wed, February 16, 2011 2:33:03 PM
> Subject: [DynoMotion] Re: Making analog servo with KFlop + Kanalog
>
>  
> To get started I tried to read the values of ADC0 that I had a small voltage on
> JP6 ADC0 using the console command ADC0. result is always 0.
> I used the console to set DACO=2000 and I can see that on the analog IO screen
> but not on JP11 DAC0.
> What am I doing wrong.
> Bob
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > To use an ADC as the feedback for a servo loop select Axis Input Mode = ADC
> >on
> >
> > the Configuration Screen.
> >
> > You can specify Input Gains and Offsets.  Setting a Gain of -1 would invert
> >the
> >
> > input.
> >
> > If you need to sum 2 inputs you would need to write a C Program to do this.
> >
> > There is no direct support for that slow of a PWM output to an opto output. 
> >But
> >
> > you can do it with a C program something like shown below.  Configure the
> >servo
> >
> > axis as a dummy DAC output so the axis calculates the  ch0->Output value, but
> >
> > have the C program use the value to control the opto output.
> >
> > The added Kanalog I/O is described under the Kanalog Section here:
> >
> > http://www.dynomotion.com/Help
> >
> > I hope this helps
> > TK
> >
> >
> > #include "KMotionDef.h"
> > main()
> > {
> >     int v,i=0,k;
> >  
> >     for (;;)
> >     {
> >         WaitNextTimeSlice();
> >         v=ch0->Output;  // desired output
> >   
> >         k = ((i&1)   << 7)|  // bit reverse i
> >             ((i&2)   << 5)|
> >             ((i&4)   << 3)|
> >             ((i&8)   << 1)|
> >             ((i&16)  >> 1)|
> >             ((i&32)  >> 3)|
> >             ((i&64)  >> 5)|
> >             ((i&128) >> 7);
> >  
> >        if (k >= v)
> >             SetBit(148);
> >         else
> >             ClearBit(148);
> >   
> >         i = ++i & 255;  // 8 bit counter
> >     }
> > }
> >
> >
> >  
> >
> >
> >
> > ________________________________
> > From: "b.burig@" <b.burig@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Wed, February 16, 2011 9:23:04 AM
> > Subject: [DynoMotion] Making analog servo with KFlop + Kanalog
> >
> >  
> > I have no idea how to use the low voltage ADCs on JP12 of Kanalog board. Or how
> >
> > to set up an analog loop on the Kanalog. Servoes are not new to me, made
> > hundreds of all types.
> >
> > Can I sum 2 inputs?
> > Can I invert the polarity of an input?
> >
> > I want to make an analog servo with PID loop with analog command generated by a
> >
> > temperature monitoring device. This input would control the temperature loop by
> >
> > outputting a PWM signal (say less than 60 cycles) to an Opto output (say IO
> >148)
> >
> > to control a heater.
> >
> >
> > In addition, I want to make another loop using a humidity sensor. It could be a
> >
> > simple on-off control, so I would set a reference, and read the input voltage
> > (input to ADC) and compare to the reference. If needed this may need to
> >expanded
> >
> > to PID loop as well.
> >
> > Is there a manual for Kanalog.
> >
>
Group: DynoMotion Message: 924 From: Tom Kerekes Date: 2/17/2011
Subject: Re: Making analog servo with KFlop + Kanalog
Hi Bob,
 
Yes I see a bug with the Console ADC Command.  Sorry about that.
 
As a workaround just look at the Analog Status or run the program below to print the value.
 
Additionally if you configure an axis for ADC input you can display the ADC value as the Axis Position with the Pos<N> Console Command.
 
#include "KMotionDef.h"
main()
{
    printf("ADC0=%d\n",ADC(0));
}

TK